<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 通过在子类内部通过call执行一遍Parent实现把parent的属性放在子类自身上
      //   缺点：可能会覆盖子类本身的属性，无法继承父类自身的prototype属性
      function Parent() {
        this.name = "parent";
        this.say = function () {
          console.log(this.name);
        };
      }
      Parent.prototype.test = 1;
      function Child() {
        Parent.call(this);
        this.name = "child";
      }
      let p = new Child();
      p.say();
      //   无法拿到父类自身的prototype属性
      console.log(p.test);
    </script>
  </body>
</html>
